#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
    deque<int> dq;

    dq.push_back(1); // [1]
    dq.push_back(2); // [1, 2]
    dq.push_back(3); // [1, 2, 3]

    dq.push_front(4); // [4, 1, 2, 3]
    dq.push_front(5); // [5, 4, 1, 2, 3]


    // 迭代器来遍历枚举元素
    for(deque<int>::iterator it = dq.begin(); it!=dq.end(); it++)
        cout << *it << endl;

    // 来一个指定序列：3, 2, 5, 1, 4
    cout << dq.back() << endl; dq.pop_back();
    cout << dq.back() << endl; dq.pop_back();
    cout << dq.front() << endl; dq.pop_front();
    cout << dq.back() << endl; dq.pop_back();
    cout << dq.front() << endl; dq.pop_front();

    return 0;
}
